home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swags_z.zip / STRINGS.SWG / 0082_Basic-like Strings.pas < prev    next >
Pascal/Delphi Source File  |  1994-08-24  |  2KB  |  49 lines

  1. {
  2.   *****************************************************************
  3.   *                         Basic Strings                         *
  4.   *                               by                              *
  5.   *                         Todd A. Jacobs                        *
  6.   *                                                               *
  7.   * Duplicates the Basic string functions Left$, Right$, and Mid$ *
  8.   *****************************************************************
  9.  
  10.   A very simple unit to assist in parsing strings using familiar
  11.   Basic commands.  StrName is self-explanatory.  NumChars is the
  12.   length of the string to be returned, and StartPos is the index to
  13.   start at for the Mid$ (aka MidStr) function.
  14.  
  15.   Released into the public domain, I hope someone will: a) find it
  16.   useful, and b) add support for comma-delimited and space-delimited
  17.   input (a la Basic).
  18.  
  19.   Comments may be directed to 1:109/182 or tjacobs@epub.com.
  20.   Flames may be directed to the NUL device.  :)
  21. }
  22.  
  23. Unit BasicStr;
  24.  
  25. Interface
  26.  
  27. Function MidStr  ( StrName: String; StartPos, NumChars : Integer) : String;
  28. Function LeftStr ( StrName: String; NumChars : Integer) : String;
  29. Function RightStr( StrName: String; NumChars : Integer) : String;
  30.  
  31. Implementation
  32.  
  33. Function MidStr;
  34. Begin
  35.   MidStr := Copy ( StrName, StartPos, NumChars);
  36. End; {Mid$}
  37.  
  38. Function LeftStr;
  39. Begin
  40.   LeftStr := Copy ( StrName, 1, NumChars);
  41. End; {Left$}
  42.  
  43. Function RightStr;
  44. Begin
  45.   RightStr := Copy ( StrName, ( Length(StrName) - (NumChars - 1)), NumChars);
  46. End; {Right$}
  47.  
  48. End. {Unit}
  49.